const router = require("koa-router")();
const { userAdd, userLogin, userGetDetailsById } = require("../controllers/user");
const { koaBody } = require("koa-body");

router.prefix("/users");

router.get("/", function (ctx, next) {
  ctx.body = "this is a users response!";
});

router.get("/bar", function (ctx, next) {
  ctx.body = "this is a users/bar response";
});
router.post("/add", userAdd);
router.post(
  "/login",
  koaBody({
    multipart: true, // 支持文件上传
    formidable: {
      maxFileSize: 200 * 1024 * 1024, // 设置上传文件大小最大限制，默认2M
    },
  }),
  userLogin
);
router.get("/getUserById", userGetDetailsById);

module.exports = router;
